package com.wxm.servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.xm.dao.ComdeDaoImp;
import com.xm.dao.DesignerDaolmpl;
import com.xm.dao.LianXiDaoImpl;
import com.xm.entity.Comdetail;
import com.xm.entity.Designer;
import com.xm.entity.LianXi;

/**
 * 关于我们相关方法请求 全查 地址:
 * http://localhost:8080/javaweb-Furniture/AboutServlet?method=comAllList
 * Servlet implementation class AboutServlet
 */
@WebServlet("/AboutServlet")
public class AboutServlet extends BaseServlet {

	public void comAllList(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// 公司信息
		ComdeDaoImp dao = new ComdeDaoImp();
		Comdetail com = dao.getCom();
		// 单个联系信息
		LianXiDaoImpl dao3 = new LianXiDaoImpl();
		LianXi com2 = dao3.getCom().get(0);
		// 公司信息存储到作用域
		HttpSession session = req.getSession();
		session.setAttribute("com", com);
		session.setAttribute("com2", com2);
		
		// 调用设计师dao层方法
		DesignerDaolmpl desDao = new DesignerDaolmpl();
		ArrayList<Designer> allDesigner = desDao.getAllDesigner();
		// 设计师信息存储到作用域
		req.setAttribute("allDesigner", allDesigner);

		// 跳转页面（请求转发）
		req.getRequestDispatcher("about.jsp").forward(req, resp);
	}

}
